package com.xywy.common.net;

import android.widget.Toast;

import com.xywy.common.constants.ErrorCode;

public class AsyncHttpClient {
	private AsyncHttpClient() {
	}

	/**
	 * 静态单例
	 */
	public static AsyncHttpClient getInstance() {
		return singletonHolder.instance;
	}

	private static class singletonHolder {
		private static AsyncHttpClient instance = new AsyncHttpClient();
	}

	public void exeute(Parser parser,
			OnResultListenerAdapter onResultListenerAdapter) {
		if (NetUtil.hasNetwork(parser.context)) {
			new MyAsyncTask().executeProxy(parser, onResultListenerAdapter);
		} else {
			Toast.makeText(parser.context, "暂无网络连接", Toast.LENGTH_SHORT).show();
			onResultListenerAdapter.onNoNetWork(parser,
					ErrorCode.ERR_NO_NETWORK);
		}
	}
}
